package com.project.controller;

import com.project.bean.CommentBean;
import com.project.bean.EUserBean;
import com.project.service.ICommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author lyl
 * description:
 */
@RestController
@RequestMapping("comment")
public class CommentController {
    @Autowired
    private ICommentService iCommentService;

    @RequestMapping("add")
    public String add(String comment, int productId, HttpServletRequest request) {
        EUserBean userBean = (EUserBean) request.getSession().getAttribute("loginUser");
        System.out.println("userBean=" + userBean);
        CommentBean commentBean = new CommentBean(comment, userBean.getUserId(), productId);
        iCommentService.add(commentBean);
        return "ok";
    }
}
